package com.ptu.controller.user;

import com.ptu.entity.SeckillProduct;
import com.ptu.server.SeckillProductServer;
import com.ptu.util.Result;
import com.ptu.vo.SeckillProductVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userSeckillProductController")
@Tag(name = "秒杀商品模块")
@RequestMapping("/seckillProduct")
public class SeckillProductController {

    @Autowired
    private SeckillProductServer seckillProductServer;

    @Operation(summary = "获取秒杀商品列表")
    @GetMapping("/list")
    public List<SeckillProductVO> list() {
        System.out.println("用户获取秒杀商品列表");
        return seckillProductServer.userGetList();
    }

    @Operation(summary = "获取秒杀商品详情")
    @GetMapping("/detail/{id}")
    public Result<SeckillProduct> detail(@PathVariable Long id) {
        System.out.println("获取秒杀商品详情");
        SeckillProduct seckillProduct =seckillProductServer.detail(id);
        return Result.success(seckillProduct);
    }
}
